<script setup >
import { BigNumber } from "bignumber.js";
import * as _ from "lodash-es";
import data from "@data/user.json";

console.table(  data.data );
let obj = {
  a: 1,
  b: 2,
  c: 3
}
console.log( 'obj:', _.toArray( obj ) );
let a = new BigNumber( '1111222233334444555566' );
console.log( 'a:', a.toString() );
console.log( 'a:', a.toFixed() );

let b = new BigNumber( '123456789.00000000000010001' );
console.log( 'b:', b.toFixed() );

let c = new BigNumber( '123456789.00000000000010001' );
console.log( 'c:', c.toFixed() );

let d = b.plus( c )
console.log( 'd:', d.toFixed() );

let e = new BigNumber( Number.MAX_VALUE.toString() );
console.log( 'e:', e.toString() );

let f = 0.2 + 0.1;
console.log( 'f:', f );

let g1 = new BigNumber( 0.2 );
let g2 = new BigNumber( 0.1 );
let g = g1.plus( g2 );
console.log( 'g:', g.toFixed() );

let h1 = new BigNumber( '0.10' );
let h2 = new BigNumber( '8' );
let h3 = new BigNumber( '7' );
let h4 = new BigNumber( '4' );
console.log( 'h1/h2:', h1.dividedBy( h2).toFixed() , 'h3%h4:', h3.modulo( h4).toFixed());

let i1 = new BigNumber( '0.125' );
let i2 = new BigNumber( '8' );
let i = i1.times( i2);//        0.125*8 = 1
console.log( 'i:', i.toFixed() );

let j = new BigNumber( '3.125' );
console.log( 'j:', j.integerValue().toFixed() );

let k = new BigNumber( '0.01');
console.log( 'k:', k.squareRoot().toFixed() );//sqrt为squareRoot的缩写  sqrt(0.01) = 0.1

let l = new BigNumber( '2');
console.log( 'l:', l.exponentiatedBy( 3).toFixed() );// pow为exponentiatedBy的缩写 2^3 = 8

let m = new BigNumber( '2');
let m1 = m.pow( 2);
let m2 = m1.sqrt();
console.log( 'm1:', m1.toFixed() , 'm2:', m2.toFixed());

let n = new BigNumber( 255.5);
let n1 = n.toExponential( 5); //使用科学计数法保留5位小数 2.55500e+2
let n2 = n.toFixed( 5);// 保留5位小数 255.50000
let n3 = n.toPrecision( 5);//总长度为5位  255.50
let n4 = n.toNumber();// 255.5
let n5 = n.toString(16);// 16进制 0xff.8
console.log( 'n1:', n1 , 'n2:', n2, 'n3:', n3, 'n4:', n4, 'n5:', n5);

let o = new BigNumber( '123456789.12345678');
console.log( 'o:', o.toFormat(3) ); //格式化数据 123,456,789.123

BigNumber.config( {
  DECIMAL_PLACES : 10,
  ROUNDING_MODE : BigNumber.ROUND_HALF_UP,
});
let p1 = new BigNumber( 2 );
let p2 = new BigNumber( 3 );
let p3 = new BigNumber( -3 );
console.log( '2/3=', p1.dividedBy( p2 ).toFixed() );
console.log( '2%3=', p1.modulo( p2 ).toFixed() );
console.log( '2*3=', p1.times( p2 ).toFixed() );
console.log( '2-3=', p1.minus( p2 ).toFixed() );
console.log( '2+3=', p1.plus( p2 ).toFixed() );
console.log( '2^3=', p1.exponentiatedBy( p2 ).toFixed() );
console.log( '2^-3=', p1.exponentiatedBy( p3 ).toFixed() );
console.log( '2√3=', p2.squareRoot().toFixed() );

let q = new BigNumber(2);
let q1 = q.dividedBy( 3)
let q2 = q1.toFraction(10);// 将小数转换为分数
console.log( '2/3=', q1.toFixed() );
console.log(q1.toFixed(), '=', q2[0]["c"][0] , '/', q2[1]["c"][0] );



// console.timeEnd('test' )
</script >

<template >

</template >

<style scoped >

</style >